package cn.lds.j368.dsbank.resolver;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * JSR303 异常处理器
 */
//@ControllerAdvice  //标记该类为全局异常处理器
public class ValidatorExceptionResolver {

    private final static Logger log = LoggerFactory.getLogger(ValidatorExceptionResolver.class);

    @ExceptionHandler
    public String exception(Exception e, Model model){

        log.info("exception:{}",e.getLocalizedMessage());

        model.addAttribute("errorMsg",e.getLocalizedMessage());

        return "errors";
    }


}
